<?php
class Controller {

    /**
     *
     * @var View
     */
    public $view;
    /**
     *
     * @var Model
     */
    public $model;

    function __construct() {
        //echo 'Main controller<br />';

        $this->view = new View();

        if (Helper::isJessi()){
            $this->view->setJessiMsg($this->getRunTimeJessiMsg());
            $this->view->setJessiFooterMsg($this->getRunTimeJessiFooterMsg());
        }
    }

    public function getRunTimeJessiMsg(){
        return "hello jessi";
    }

    public function getRunTimeJessiFooterMsg(){
        return "jessi chiao";
    }



    /**
     * @param $name
     * @param string $modelPath
     */
    public function loadModel($name, $modelPath = 'models/') {
        //﻿ini_set('display_errors',1);
        //ini_set('display_startup_errors',1);
        //error_reporting(E_ALL);
        $name = $name.'_model';
        $path = $modelPath . $name.'.php';

        if (file_exists($path)) {
            require $modelPath .$name.'.php';

            $modelName = $name;

            $this->model = new $modelName();
        }
    }


}

?>
